import tushare as ts
from sqlalchemy import create_engine
from IndexDailyData import insert_history_data_index_daily
import logging
import constant

"""
指数日线行情
"""

# 日志
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
logging.debug('------------------ Start of program ---------------------')
# 初始化数据库连接:
engine = create_engine(
    constant.get_db_path(),
    max_overflow=0,  # 超过连接池大小外最多创建的连接数
    pool_size=5,  # 连接池大小
    pool_timeout=30,  # 连接池中没有线程最多等待时间，否则报错
    pool_recycle=-1,  # 多久之后对连接池中的连接进行回收（重置）-1不回收
)

pro = ts.pro_api(constant.get_pro_token())


insert_history_data_index_daily(engine, pro)


logging.debug('------------------ end of program ---------------------')